const ARRAY_METHODS = [
    'push',
    'pop',
    'shift',
    'unshift',
    'sort',
    'splice',
    'reverse'
]
const originArrMethods = Array.prototype;
export const arrMethods = Object.create(Array.prototype);

ARRAY_METHODS.map((m) => {
    arrMethods[m] = function () {
        const args = Array.prototype.slice.call(arguments),
              res = originArrMethods[m].apply(this, args),
              ob = this.__ob__;
        let newArr;
        switch (m) {
            case 'push':
            case 'unshift':
                newArr = args;
                break;
            case 'splice':
                newArr = args.slice(2);
        }
        newArr && ob.observeArr(newArr);

        return res;
    }
})